home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / lib / include / jaquith.h < prev    next >
Encoding:
C/C++ Source or Header  |  1992-10-29  |  25.7 KB  |  790 lines

  1. /*
  2.  * jaquith.h --
  3.  *
  4.  *    DATA and declarations for use by the Jaquith archive system
  5.  *
  6.  * Copyright 1992 Regents of the University of California
  7.  * Permission to use, copy, modify, and distribute this
  8.  * software and its documentation for any purpose and without
  9.  * fee is hereby granted, provided that this copyright
  10.  * notice appears in all copies.  The University of California
  11.  * makes no representations about the suitability of this
  12.  * software for any purpose.  It is provided "as is" without
  13.  * express or implied warranty.
  14.  *
  15.  * Quote:
  16.  *      The primary purpose of the DATA statement is to give names to con-
  17.  *      stants; instead of referring to pi as 3.141592653589793 at every
  18.  *      appearance, the variable PI can be given that value with a DATA
  19.  *      statement and used instead of the longer form of the constant.
  20.  *      This also simplifies modifying the program, should the value of
  21.  *      pi change.
  22.  *      -- FORTRAN manual for Xerox Computers
  23.  *
  24.  * $Header: /sprite/lib/forms/RCS/jaquith.h,v 1.0 91/02/09 13:24:52 mottsmth Exp $ SPRITE (Berkeley)
  25.  */
  26.  
  27.  
  28. #ifndef _JAQUITH
  29. #define _JAQUITH
  30.  
  31. #ifdef OSF1
  32. #define _BSD
  33. #endif
  34. #include <stdio.h>
  35. #include <errno.h>
  36. #include <sys/types.h>
  37. #include <sys/file.h>
  38. #include <sys/stat.h>
  39. #include <sys/wait.h>
  40. #include <sys/param.h>
  41. #include <sys/time.h>
  42. #include <sys/timeb.h>
  43. #include <sys/socket.h>
  44. #include <sys/ioctl.h>
  45. #include <netinet/in.h>
  46. #include <netdb.h>
  47. #ifdef sunos
  48. #include <dirent.h>
  49. #else
  50. #include <sys/dir.h>
  51. #endif
  52. #ifdef SYSV
  53. #include <strings.h>
  54. #include <utime.h>
  55. #else
  56. #include <string.h>
  57. #endif
  58. #ifdef HASLIMITSH
  59. #include <limits.h>
  60. #else
  61. #define INT_MAX 2147483647
  62. #define SHRT_MAX 64535
  63. #endif
  64. #ifdef HASSTDLIBH
  65. #include <stdlib.h>
  66. #else
  67. extern int    exit();
  68. extern int    free();
  69. extern char *    getenv();
  70. extern char *    malloc();
  71. extern int    qsort();
  72. #endif
  73. #ifdef sprite
  74. #include <bstring.h>
  75. #endif
  76. #include <pwd.h>
  77. #include <grp.h>
  78. #include <time.h>
  79. #include <varargs.h>
  80. #include <signal.h>
  81. #include <ctype.h>
  82. #include "cfuncproto.h"
  83. #include "regexp.h"
  84.  
  85. #ifndef HASSTRTOK
  86. extern char *strtok();
  87. #endif
  88.  
  89. #define DEF_SERVER "covet.CS.Berkeley.EDU"
  90. #define DEF_PORT 10001
  91. #define DEF_MGRSERVER DEF_SERVER
  92. #define DEF_MGRPORT 20001
  93. #define DEF_DEVFILE "/jaquith/dev/devconfig"
  94. #define DEF_VOLFILE "/jaquith/dev/volconfig"
  95. #define DEF_ROBOT "/dev/exbjbox5"
  96. #define DEF_ARCH "default.arch"
  97. #define DEF_ROOT "/jaquith/arch"
  98. #define DEF_FSYNCFREQ 10
  99. #define DEF_JAQLOG "/jaquith/arch/jaq.log"
  100. #define DEF_MGRLOG "/jaquith/arch/jmgr.log"
  101. #define DEF_GET "/jaquith/cmds/jfetch"
  102. #define DEF_PUT "/jaquith/cmds/jupdate"
  103. #define DEF_CLEAN "/jaquith/cmds/jclean"
  104. #define DEF_STATUS "/jaquith/cmds/jquery"
  105. #define DEF_TBUFSIZE (1024*2048)  /* default tbuf size */
  106.  
  107. #define T_MAXMSGLEN 8192      /* arbitrary constant */
  108. #define T_MAXSTRINGLEN 1024   /* arbitrary constant */
  109. #define T_MAXLABELLEN 80      /* arbitrary constant */
  110. #define T_MAXPATHLEN 255      /* limited by POSIX tar format */
  111. #define T_MAXLINELEN 256      /* for config files */
  112. #define T_VOLSIZEK 4550000    /* 8500 Exabyte P6-120 */
  113. #define T_TAPEUNIT 1024       /* min write unit for device */
  114. #define T_FILEMARKSIZE (48*1024)  /* for Exb 8500 drive */
  115. #define T_BUFSIZE (32*T_TAPEUNIT) /*  socket/disk I/O operation size */
  116. #define T_TARSIZE (32*T_TAPEUNIT)  /* tar tape I/O operation size */
  117. #define T_TBLOCK 512          /* tar unit. not adjustable */
  118.  
  119. #define ARCHMASTER "mottsmth"
  120.  
  121. #define ROOT_LOGIN "root"
  122. #define COMMENT_CHAR '#'      /* For config file comments */
  123. #define ARCHLOGFILE "log"
  124. #define MSGVERSION 1          
  125. #define ENV_ARCHIVE_VAR "JARCHIVE"
  126. #define ENV_SERVER_VAR  "JSERVER"
  127. #define ENV_PORT_VAR    "JPORT"
  128.  
  129. typedef int AuthHandle;       /* for kerberos someday */
  130.  
  131. #ifdef MEMDEBUG
  132. #define MEM_ALLOC(name,amount) Mem_Alloc(name, __LINE__, amount)
  133. #define MEM_FREE(name, ptr) Mem_Free(name, __LINE__, (char *)ptr)
  134. #define MEM_CONTROL(size, stream, flags, freeMax) \
  135.     Mem_Control(size, stream, flags, freeMax)
  136. #define MEM_REPORT(name, owner, flags) \
  137.     Mem_Report(name, __LINE__, owner, flags)
  138. #else
  139. #define MEM_ALLOC(name,amount) malloc(amount)
  140. #define MEM_FREE(name, ptr) free((char *)ptr)
  141. #define MEM_CONTROL(size, stream, flags, freeMax) {}
  142. #define MEM_REPORT(name, owner, flags) {}
  143. #endif
  144.  
  145. #ifdef ultrix
  146. #define S_ISLNK(x) (((x) & S_IFMT) == S_IFLNK)
  147. #endif
  148.  
  149. #ifdef sprite
  150. #define S_ISADIR(x) ((S_ISDIR(x)) || (S_ISRLNK(x)))
  151. #define S_ISALNK(x) ((S_ISLNK(x)) || (S_ISRLNK(x)))
  152. #define MAKERMTLINK(target, name, flag) Fs_SymLink(target, name, flag)
  153. #else
  154. #define S_ISADIR(x) (((x) & S_IFMT) == S_IFDIR)
  155. #define S_ISALNK(x) (((x) & S_IFMT) == S_IFLNK)
  156. #define S_IFRLNK 0160000
  157. #define MAKERMTLINK(target, name, flag) -1; \
  158.     printf("Don't know how to make remote link: %s\n", name);
  159. #endif
  160.  
  161. #if ((defined sunos) || (defined OSF1))
  162. typedef struct dirent DirObject;
  163. #else
  164. typedef struct direct DirObject;
  165. #endif
  166.  
  167. #if (defined(SYSV) && !defined(dynix))
  168. #define GETWD(path, pathLenPtr) getcwd(path, pathLenPtr)
  169. #else
  170. #define GETWD(path, pathLenPtr) getwd(path)
  171. #endif
  172.  
  173. extern int errno;
  174. extern int sys_nerr;
  175. extern char *sys_errlist[];
  176.  
  177. #ifdef SYSV
  178. #define STRCHR index
  179. #define STRRCHR rindex
  180. #else
  181. #define STRCHR strchr
  182. #define STRRCHR strrchr
  183. #endif
  184.  
  185. /*
  186.  * Message layouts
  187.  * 
  188.  * Each message from a T_CLIENT has a header and a body
  189.  * which is a descrimated union.
  190.  */
  191.  
  192. typedef struct T_ReqMsgHdr {
  193.     int version;              /* message version number */
  194.     int cmd;                  /* command type */
  195.     int len;                  /* length of following command data */
  196.     int flags;                /* misc flags */
  197.     AuthHandle ticket;        /* kerberos ticket */
  198. } T_ReqMsgHdr;
  199.  
  200. typedef struct T_RespMsgHdr {
  201.     int version;              /* message version number */
  202.     int len;                  /* length of following command data */
  203.     int status;               /* command status */
  204.     int errno;                /* system error number */
  205. } T_RespMsgHdr;
  206.  
  207. /*
  208.  * defines for command types. Jaquith depends on this order.
  209.  */
  210. #define T_MAXCMDS 5
  211.  
  212. #define T_CMDNULL 0
  213. #define T_CMDLS   1
  214. #define T_CMDPUT  2
  215. #define T_CMDGET  3
  216. #define T_CMDSTAT 4
  217.  
  218. /*
  219.  * defines for flags word
  220.  */
  221. #define T_LOCAL      0x01     /* Read data from local file */
  222. #define T_LINK       0x02     /* Return link itself */
  223. #define T_FOLLOWLINK 0x04     /* Return link's target */
  224. #define T_FORCE      0x08     /* Force data out to archive */
  225. #define T_SYNC       0x10     /* Write data synchronously to storage */
  226. #define T_NODATA     0x20     /* Return metadata only */
  227. #define T_NEWVOL     0x40     /* Force data to a new volume. */
  228. #define T_COMPRESS   0x80     /* Compress data before storing */
  229.  
  230. /*
  231.  * defines for status. Interpreted by MakeErrorMsg
  232.  */
  233. #define T_ACTIVE    -2
  234. #define T_FAILURE   -1
  235. #define T_SUCCESS    0
  236. #define T_BADVERSION 1
  237. #define T_BADMSGFMT  2
  238. #define T_BADCMD     3
  239. #define T_NOACCESS   4
  240. #define T_IOFAILED   5
  241. #define T_INDXFAILED 6
  242. #define T_BUFFAILED  7
  243. #define T_ADMFAILED  8
  244. #define T_ROBOTFAILED 9
  245. #define T_NOVOLUME   10
  246. #define T_EXECFAILED 11
  247. #define T_NOARCHIVE  12
  248. #define T_MAXERR   13
  249.  
  250. typedef struct T_FileStat {
  251.     char *fileName;           /* file name */
  252.     char *linkName;           /* target file name if this is a symlink */
  253.     char *uname;              /* user name */
  254.     char *gname;              /* group name */
  255.     char *abstract;           /* arbitrary user text string */
  256.     char *fileList;           /* List of filenames in a directory */
  257.     time_t vtime;             /* archive date/time */
  258.     time_t atime;             /* access date/time */
  259.     int volId;                /* volume number */
  260.     int filemark;             /* filemark number */
  261.     int tBufId;               /* buffer number */
  262.     int offset;               /* offset of file within buffer */
  263.     int mode;                 /* protection and type */
  264.     int uid;                  /* user id */
  265.     int gid;                  /* group id */
  266.     time_t mtime;             /* modification time */
  267.     int size;                 /* size in bytes. Should be larger */
  268.     dev_t rdev;               /* device id if this is a device */
  269. } T_FileStat;
  270.  
  271. typedef struct Caller {
  272.     char *userName;           /* User login name */
  273.     char *groupName;          /* User group name */
  274.     char *hostName;           /* Host name */
  275. } Caller;
  276.  
  277. /**************************** utils ****************************/
  278.  
  279. #define BAIL_PRINT  0
  280. #define BAIL_PERROR 1
  281. #define BAIL_HERROR 2
  282.  
  283. extern void  Utils_Bailout       _ARGS_ ((char *msg, int disposition));
  284. extern void  Utils_GetWorkingDir _ARGS_ ((char *path, int *pathLen));
  285. extern char *Utils_MakeFullPath  _ARGS_ ((char *name));
  286. extern int   Utils_CheckName     _ARGS_ ((char *name, int noWhiteSpace));
  287. extern char *Utils_ReadLine      _ARGS_ ((FILE *stream, int stripFlag));
  288. extern int   Utils_StringHashProc _ARGS_ ((Hash_Key key,int keyLen, int size));
  289. extern int   Utils_IntegerHashProc _ARGS_ ((Hash_Key key,int keyLen,int size));
  290. extern int   Utils_CvtInteger    _ARGS_ ((char *string, int low,
  291.                       int high, int *valPtr));
  292. extern char *Utils_GetLoginByUid _ARGS_ ((int uid));
  293. extern char *Utils_GetGroupByGid _ARGS_ ((int gid));
  294. extern int   Utils_GetUidByLogin _ARGS_ ((char *login));
  295. extern int   Utils_GetGidByGroup _ARGS_ ((char *group));
  296. extern int   Utils_SendMail      _ARGS_ ((char *recipient, char *msg,
  297.                       char *type));
  298. extern void  Utils_FreeFileStat  _ARGS_ ((T_FileStat *statInfoPtr, int flag));
  299. extern T_FileStat *Utils_CopyFileStat  _ARGS_ ((T_FileStat *statInfoPtr));
  300. extern int   Utils_GetOk         _ARGS_ ((char *msg));
  301. extern int   Utils_GetInteger    _ARGS_ ((char *msg, int low, int high));
  302.  
  303. /**************************** mem ****************************/
  304.  
  305. #define MEM_MAXALLOC 8*1024
  306.  
  307. extern char *Mem_Alloc   _ARGS_ ((char *callerName, int line, int blockSize));
  308. extern int   Mem_Free    _ARGS_ ((char *callerName, int line, char *blockPtr));
  309. extern char *Mem_Dup     _ARGS_ ((char *callerName, int line, char *string));
  310. extern char *Mem_Cat     _ARGS_ ((char *callerName, int line, int argCnt,...));
  311. extern void  Mem_Report  _ARGS_ ((char *callerName, int line,
  312.                   char *owner, int reportFlags));
  313. extern void  Mem_Control _ARGS_ ((int maxBlockSize, FILE *outStream,
  314.                   int traceFlags, int freeMax));
  315.  
  316. /*
  317.  * Bit definitions for traceFlags parameter
  318.  */
  319.  
  320. /*
  321.  * Enable tracing.
  322.  * Default: off
  323.  */
  324. #define TRACEMEM         0x01
  325.  
  326. /*
  327.  * print msg at each alloc and free call.
  328.  * Default: off
  329.  */
  330. #define TRACECALLS       0x02
  331.  
  332. /*
  333.  * print statistics for calling routine after each alloc and free call
  334.  * Default: off
  335.  */
  336. #define TRACESTATS       0x04
  337. /*
  338.  * check border around blocks for overwrite after each alloc/free call
  339.  * Default: off (each block is checked when it's freed.)
  340.  */
  341. #define CHECKALLBLKS     0x08
  342.  
  343. /*
  344.  * Blocks allocated while TRACEMEM == 0 will not be in the database.
  345.  * If later tracing is enabled and one of these blocks is freed,
  346.  * there will be no record of it in the database and JmsFree will abort.
  347.  * A similar problem occurs if only some of the code is instrumented so
  348.  * that only some allocs are traced.
  349.  * 
  350.  * Set IGNOREMISSINGBLK == 1 to ignore such blocks or WARNMISSINGBLK
  351.  * to print a message but continue. The bits are mutually exclusive.
  352.  * Default: issue message and abort (Both bits off).
  353.  */
  354. #define IGNOREMISSINGBLK 0x10
  355. #define WARNMISSINGBLK 0x20
  356.  
  357. /*
  358.  * for ownerName parameter
  359.  */
  360. #define ALLROUTINES "*"
  361.  
  362. /*
  363.  * report flags
  364.  */
  365. #define SORTBYREQ   0x01
  366. #define SORTBYADDR  0x02
  367. #define SORTBYOWNER 0x04
  368. #define SORTBYSIZE  0x08
  369.  
  370. /*
  371.  * Include freed blocks in report.
  372.  * default: off
  373.  */
  374. #define REPORTALLBLKS 0x10
  375.  
  376.  
  377. /**************************** str ****************************/
  378.  
  379. extern int   Str_Match     _ARGS_ ((char *s1, char *s2));
  380. extern char **Str_Split    _ARGS_ ((char *string, char splitChar, 
  381.                     int *partCnt, int elide,
  382.                     char **insidePtrPtr));
  383. extern char *Str_Dup       _ARGS_ ((char *string));
  384. extern char *Str_Cat       _ARGS_ ((int argCnt,...));
  385. extern char *Str_Quote     _ARGS_ ((char *src, char *metachars));
  386. extern int   Str_Unquote   _ARGS_ ((char *src));
  387. extern int   Str_StripDots _ARGS_ ((char *src));
  388.  
  389.  
  390. /**************************** tbuf ****************************/
  391.  
  392. #define MAXTBUFSIZE 1024*1024
  393. #define READING 0
  394. #define WRITING 1
  395.  
  396. extern int   TBuf_Open        _ARGS_ ((char *path, int name, int *fdPtr,
  397.                        int *hdrFdPtr, int mode));
  398. extern int   TBuf_Close       _ARGS_ ((int tBufFd, int tHdrFd,
  399.                        int termFlag));
  400. extern int   TBuf_Pad         _ARGS_ ((int tBufFd, int len, int blockSize));
  401. extern int   TBuf_WriteTarHdr _ARGS_ ((int fd, T_FileStat *inData));
  402. extern int   TBuf_ParseTarHdr _ARGS_ ((char *inBuf, T_FileStat *outData));
  403. extern int   TBuf_FindFile    _ARGS_ ((int tBufFd, T_FileStat *statInfoPtr));
  404. extern int   TBuf_Delete      _ARGS_ ((char *rootPath, char *arch,
  405.                        int firstTBuf, int lastTBuf));
  406.  
  407. extern int   TBuf_Terminate   _ARGS_ ((int tBufStream, int tBufSize,
  408.                        int unit));
  409.  
  410.  
  411. /**************************** lock ****************************/
  412.  
  413. typedef struct lock_handle {
  414.     int lockFd;
  415.     int lockMode;
  416.     char lockName[T_MAXPATHLEN];
  417. } Lock_Handle;
  418.  
  419. #define LOCK_BLOCK 0
  420. #define LOCK_NOBLOCK 1
  421. #define LOCK_RMCONFIRM 1
  422.  
  423. extern int  Lock_Acquire   _ARGS_ ((char *name, int blockFlag,
  424.                     Lock_Handle *handlePtr));
  425. extern int  Lock_Release   _ARGS_ ((Lock_Handle *handlePtr));
  426. extern void Lock_RemoveAll _ARGS_ ((char *dirPath, int confirmFlag));
  427.  
  428. /**************************** admin ****************************/
  429.  
  430. /*
  431.  * Archive's configuration state
  432.  */
  433. typedef struct archConfig {
  434.     char mgrServer[T_MAXSTRINGLEN]; /* name of jmgr server */
  435.     int mgrPort;              /* port where jmgr listens */
  436.     int tBufSize;             /* tbuf target size */
  437. } ArchConfig;
  438.  
  439. /*
  440.  * Archive's volume state
  441.  */
  442. typedef struct volinfo {
  443.     int volId;                /* current volume id */
  444.     int filemark;             /* Last filemark written. i.e EOD */
  445.     int volSpace;             /* remaining volume space in K bytes */
  446.     int lastTBuf;             /* last tBuf written. Should be 2*filemark*/
  447. } VolInfo;
  448.  
  449. /*
  450.  * Archive's buffer state
  451.  */
  452. typedef struct metaInfo {
  453.     int tBufSize;             /* Current size of buffer */
  454.     int tHdrSize;             /* Current size of buffer hdr */
  455.     int fileCnt;              /* Number of files in tBuf */
  456.     int tBufPad;              /* Pad on buffer for tar */
  457. } MetaInfo;
  458.  
  459. /*
  460.  * Volume's owner
  461.  */
  462. typedef struct volowner {
  463.     char *owner;              /* owning archive name */
  464.     int minTBuf;              /* first tbuf on volume */
  465.     int maxTBuf;              /* last tbuf on volume */
  466. } VolOwner;
  467.  
  468. /*
  469.  * Volume config file entry
  470.  */
  471. typedef struct volConfig {
  472.     int volId;                /* volume id */
  473.     int location;             /* location */
  474.     char volLabel[T_MAXLABELLEN]; /* name */
  475. } VolConfig;
  476.  
  477. /*
  478.  * Device config file entry
  479.  */
  480. typedef struct devConfig {
  481.     char name[T_MAXPATHLEN];  /* name of device */
  482.     int location;             /* location */
  483. } DevConfig;
  484.  
  485. extern int   Admin_CheckAuth     _ARGS_ ((char *archName, Caller callerPtr,
  486.                       char *permPtr));
  487. extern int   Admin_AddAuth       _ARGS_ ((char *archName, Caller callerPtr,
  488.                       char perm));
  489. extern int   Admin_ReadArchConfig _ARGS_ ((char *archName,
  490.                        ArchConfig *archConfigPtr));
  491. extern int   Admin_WriteArchConfig _ARGS_ ((char *archName,
  492.                         ArchConfig *archConfigPtr));
  493. extern int   Admin_GetCurTBuf    _ARGS_ ((char *archName, int *tBufIdPtr));
  494. extern int   Admin_SetCurTBuf    _ARGS_ ((char *archName, int tBufId));
  495. extern FILE *Admin_OpenVolInfo   _ARGS_ ((char *archName,
  496.                       Lock_Handle *lockHandlePtr));
  497. extern int   Admin_CloseVolInfo   _ARGS_ ((Lock_Handle *lockHandlePtr,
  498.                        FILE *volStream));
  499. extern int   Admin_ReadVolInfo   _ARGS_ ((FILE *volStream, VolInfo *archPtr));
  500. extern int   Admin_WriteVolInfo  _ARGS_ ((FILE *volStream, VolInfo *archPtr));
  501. extern int   Admin_AvailVolInfo  _ARGS_ ((char *archPath));
  502. extern FILE *Admin_OpenMetaInfo  _ARGS_ ((char *archName, int tBufId));
  503. extern int   Admin_CloseMetaInfo _ARGS_ ((FILE *metaStream));
  504. extern int   Admin_ReadMetaInfo  _ARGS_ ((FILE *metaStream, MetaInfo *archPtr));
  505. extern int   Admin_WriteMetaInfo _ARGS_ ((FILE *metaStream, MetaInfo *archPtr));
  506. extern int   Admin_CvtTBufId     _ARGS_ ((char *archPath, int tBufId,
  507.                       int *volIdPtr, int *blkIdPtr));
  508. extern int   Admin_UpdateLRU     _ARGS_ ((char *rootPath, char *archive,
  509.                       int tBufId));
  510. extern int   Admin_RemoveLRU     _ARGS_ ((char *rootPath, char *archive,
  511.                       int *tBufIdPtr));
  512. extern int   Admin_GetDiskUse    _ARGS_ ((char *filename,
  513.                       int *percentFreePtr,
  514.                       long *blocksFreePtr));
  515. extern VolOwner *Admin_FindVolOwner _ARGS_ ((int volId, char *root,
  516.                          char *archPattern));
  517. extern int   Admin_ReadDevConfig _ARGS_ ((char *root, DevConfig *list,
  518.                       int *cntPtr));
  519. extern int   Admin_WriteDevConfig _ARGS_ ((char *file, DevConfig *list,
  520.                        int cnt));
  521. extern int   Admin_ReadVolConfig _ARGS_ ((char *file, VolConfig *list,
  522.                       int *cntPtr));
  523. extern int   Admin_WriteVolConfig _ARGS_ ((char *file, VolConfig *list,
  524.                        int cnt));
  525. extern int   Admin_GetFreeVol     _ARGS_ ((char *root, int *volIdPtr));
  526. extern int   Admin_PutFreeVol     _ARGS_ ((char *root, int volId));
  527.  
  528. /**************************** hash ****************************/
  529.  
  530. #define MAXHASHSIZE 1000
  531.  
  532. typedef int Hash_ClientData;
  533. typedef char *Hash_Key;
  534.  
  535. typedef struct Hash_Node {
  536.     Hash_Key key;
  537.     int keyLen;
  538.     Hash_ClientData datum;
  539. } Hash_Node;
  540.  
  541. typedef struct Hash_Handle {
  542.     char *name;               /* name of table for debugging */
  543.     int tabSize;              /* # entries in hash table */
  544.     Hash_Node *tab;           /* hash table */
  545.     int stringSize;           /* size of string table */
  546.     char *stringTab;          /* ptr to string space */
  547.     int stringUsed;           /* amount of string space in use */
  548.     int (*hashFunc)();        /* hashing function */
  549.     int freeData;             /* 1==give dead data values to free() */
  550.     int tabGrowCnt;           /* statistics */
  551.     float tabFill;
  552.     int stringGrowCnt;
  553.     float stringFill;
  554.     int insertCnt;
  555.     int deleteCnt;
  556.     int lookupCnt;
  557.     int updateCnt;
  558.     int probeCnt;         
  559. } Hash_Handle;
  560.  
  561. typedef struct Hash_Stat {
  562.     int tabSize;              /* table space */
  563.     int tabGrowCnt;           /* number table reallocations */
  564.     float avgTabFill;         /* avg use at time of reallocation */
  565.     int stringSize;           /* string space */
  566.     int stringGrowCnt;        /* # of string table reallocations */
  567.     float avgStringFill;      /* avg use at time of reallocation */
  568.     int insertCnt;            /* # inserts done */
  569.     int deleteCnt;            /* # deletes done */
  570.     int lookupCnt;            /* # lookups done */
  571.     int updateCnt;            /* # updates done */
  572.     float avgProbeCnt;        /* avg # probes per operation */
  573. } Hash_Stat;
  574.  
  575. extern Hash_Handle *Hash_Create  _ARGS_ ((char *name, int size,
  576.                       int (*hashFunc)(),
  577.                       int freeData));
  578. extern void     Hash_Destroy _ARGS_ ((Hash_Handle *hashPtr));
  579. extern int      Hash_Insert  _ARGS_ ((Hash_Handle *hashPtr,
  580.                       Hash_Key key,
  581.                       int keyLen,
  582.                       Hash_ClientData datum));
  583. extern int      Hash_Delete  _ARGS_ ((Hash_Handle *hashPtr,
  584.                       Hash_Key key,
  585.                       int keyLen));
  586. extern int      Hash_Lookup  _ARGS_ ((Hash_Handle *hashPtr,
  587.                       Hash_Key key,
  588.                       int keyLen,
  589.                       Hash_ClientData *datumPtr));
  590. extern int      Hash_Update  _ARGS_ ((Hash_Handle *hashPtr,
  591.                       Hash_Key key,
  592.                       int keyLen,
  593.                       Hash_ClientData datum));
  594. extern void     Hash_Iterate _ARGS_ ((Hash_Handle *hashPtr, 
  595.                       int (*func)(),
  596.                       int *callVal));
  597. extern void     Hash_Stats   _ARGS_ ((Hash_Handle *hashPtr,
  598.                       Hash_Stat *statPtr));
  599.  
  600. #define HASH_ITER_REMOVE_STOP -3
  601. #define HASH_ITER_REMOVE_CONT -2
  602. #define HASH_ITER_STOP -1
  603. #define HASH_ITER_CONTINUE 0
  604.  
  605. /**************************** queue ****************************/
  606.  
  607. typedef int Q_ClientData;
  608.  
  609. typedef struct Q_Node {
  610.     struct Q_Node *link;
  611.     int priority;
  612.     Q_ClientData datum;
  613. } Q_Node;
  614.  
  615. typedef struct Q_Handle {
  616.     Q_Node *head;
  617.     Q_Node *tail;
  618.     int count;
  619.     int freeData;
  620.     char *name;
  621. } Q_Handle;
  622.  
  623. extern Q_Handle *   Q_Create  _ARGS_ ((char *qName, int freeData));
  624. extern void         Q_Destroy _ARGS_ ((Q_Handle *qPtr));
  625. extern void         Q_Add     _ARGS_ ((Q_Handle *qPtr,
  626.                        Q_ClientData clientData,
  627.                        int priority));
  628. extern Q_ClientData Q_Remove  _ARGS_ ((Q_Handle *qPtr));
  629. extern int          Q_Count   _ARGS_ ((Q_Handle *qPtr));
  630. extern Q_ClientData Q_Peek    _ARGS_ ((Q_Handle *qPtr));
  631. extern void         Q_Print   _ARGS_ ((Q_Handle *qPtr, FILE *fd));
  632. extern int          Q_Iterate _ARGS_ ((Q_Handle *qPtr,
  633.                        int (*func)
  634.                        (Q_Handle *,
  635.                     Q_ClientData *clientdata,
  636.                     int *,
  637.                     int *),
  638.                        int *callVal));
  639.  
  640. #define Q_TAILQ (int)INT_MAX
  641. #define Q_HEADQ (int)0
  642.  
  643. #define Q_ITER_REMOVE_STOP -3
  644. #define Q_ITER_REMOVE_CONT -2
  645. #define Q_ITER_STOP -1
  646. #define Q_ITER_CONTINUE 0
  647.  
  648.  
  649. /**************************** dev ****************************/
  650.  
  651. typedef struct VolStatus {
  652.     int speed;
  653.     int density;
  654.     int remaining;
  655.     int position;
  656.     int writeProtect;
  657. } VolStatus;
  658.  
  659. extern int   Dev_MoveVolume   _ARGS_ ((int stream, int src, int dest));
  660. extern int   Dev_OpenVolume   _ARGS_ ((char *name, int flags));
  661. extern int   Dev_CloseVolume  _ARGS_ ((int stream));
  662. extern int   Dev_ReadVolume   _ARGS_ ((int stream, char *buf, int cnt));
  663. extern int   Dev_WriteVolume  _ARGS_ ((int stream, char *buf, int cnt));
  664. extern int   Dev_UnloadVolume _ARGS_ ((char *devName));
  665. extern int   Dev_SeekVolume   _ARGS_ ((int stream, int blkId, int absolute));
  666. extern int   Dev_WriteEOF     _ARGS_ ((int stream, int count));
  667. extern int   Dev_ReadVolLabel _ARGS_ ((int stream, int location, char *label));
  668. extern int   Dev_CvtVolLabel  _ARGS_ ((char *label));
  669. extern int   Dev_InitRobot    _ARGS_ ((int stream));
  670. extern int   Dev_GetVolStatus _ARGS_ ((int stream, VolStatus *volStatusPtr));
  671. extern int   Dev_DisplayMsg   _ARGS_ ((int stream, char *msg, int style));
  672. extern int   Dev_OpenDoor     _ARGS_ ((int stream));
  673. extern int   Dev_RemoveVolume _ARGS_ ((int stream, int src));
  674. extern int   Dev_InsertVolume _ARGS_ ((int stream, int dest));
  675.  
  676. #define DEV_RELATIVE 0
  677. #define DEV_ABSOLUTE 1
  678.  
  679. /**************************** sock ****************************/
  680.  
  681. extern int  Sock_SetupSocket  _ARGS_ ((int port, char *server,
  682.                        int dieFlag));
  683. extern int  Sock_SetupEarSocket  _ARGS_ ((int *portPtr));
  684. extern void Sock_SetSocket    _ARGS_ ((int sock, char *bufPtr, int bufSize));
  685. extern int  Sock_ReadSocket   _ARGS_ ((int sock));
  686. extern int  Sock_SendRespHdr  _ARGS_ ((int sock, int, int));
  687. extern void Sock_ReadRespHdr  _ARGS_ ((int sock, T_RespMsgHdr *resp));
  688.  
  689. extern int  Sock_ReadInteger  _ARGS_ ((int sock, int *intPtr));
  690. extern int  Sock_ReadShort    _ARGS_ ((int sock, short *shortPtr));
  691. extern int  Sock_ReadString   _ARGS_ ((int sock, char **bufPtr,
  692.                        int bufLen));
  693. extern int  Sock_ReadNBytes   _ARGS_ ((int sock, char *buf, int bufLen));
  694.  
  695. extern int  Sock_WriteInteger _ARGS_ ((int sock, int val));
  696. extern int  Sock_WriteShort   _ARGS_ ((int sock, int shortVal));
  697. extern int  Sock_WriteString  _ARGS_ ((int sock, char *buf, int bufLen));
  698. extern int  Sock_WriteNBytes  _ARGS_ ((int sock, char *buf, int bufLen));
  699. extern char *Sock_PackData    _ARGS_ ((char *fmt, char **objArray,
  700.                        int *packedLenPtr));
  701. extern int  Sock_UnpackData   _ARGS_ ((char *fmt, char *buf,
  702.                        int *countPtr, char **objArray));
  703. extern void Sock_SendReqHdr   _ARGS_ ((int sock, int cmd,
  704.                        AuthHandle ticket, int recurse,
  705.                        char *mail, char *arch,int force));
  706.  
  707. /**************************** ttime ****************************/
  708.  
  709. long   Time_Stamp       _ARGS_ (());
  710. time_t Time_GetCurDate  _ARGS_ (());
  711. int    Time_Compare     _ARGS_ ((time_t time1, time_t time2,
  712.                  int dateOnly));
  713. char  *Time_CvtToString _ARGS_ ((time_t *time));
  714. int    getindate        _ARGS_ ((char *datePtr, struct timeb *timebPtr));
  715. int    getindatepair    _ARGS_ ((char *datePtr, struct timeb *timebPtr1,
  716.                  struct timeb *timePtr2));
  717.  
  718. /**************************** tlog ****************************/
  719.  
  720. #define LOG_FAIL 0x01
  721. #define LOG_MAJOR 0x02
  722. #define LOG_MINOR 0x04
  723. #define LOG_TRACE 0x08
  724. #define LOG_MAX_DETAIL 4
  725.  
  726. extern int   Log_Event      _ARGS_ ((char *src, char *msg, int level));
  727. extern int   Log_Open       _ARGS_ ((char *logName));
  728. extern int   Log_Close      _ARGS_ (());
  729. extern void  Log_SetDetail  _ARGS_ ((int detail));
  730. extern int   Log_AtomicEvent _ARGS_ ((char *src, char *msg, char *logName));
  731.  
  732. /**************************** indx ****************************/
  733.  
  734. typedef struct QuerySpec {
  735.     int firstVer;
  736.     int lastVer;
  737.     time_t firstDate;
  738.     time_t lastDate;
  739.     char *owner;
  740.     char *group;
  741.     int flags;
  742.     int recurse;
  743.     regexp *compAbstract;
  744.     char *fileName;
  745. } QuerySpec;
  746.  
  747. /* queryspec.flags definitions */
  748. #define QUERY_MODDATE 0x01
  749.  
  750. int   Indx_Open     _ARGS_ ((char *pathName, char *openOptions,
  751.                  FILE **indxStrPtr));
  752. int   Indx_Close    _ARGS_ ((FILE *str));
  753. int   Indx_Read     _ARGS_ ((char *fileName, T_FileStat *statInfoPtr,
  754.                  FILE *indxStream));
  755. int   Indx_MakeIndx _ARGS_ ((char *archPath, char *filePath, char *indxPath));
  756. int   Indx_MakeIndxList _ARGS_ ((char *archPath, char *filePath,
  757.                  Q_Handle *indxQueue));
  758. int   Indx_Match    _ARGS_ ((QuerySpec *spec, char *indxPath, char *archPath,
  759.                  char *userName, char *groupName, 
  760.                  int (*receiveProc)(), ReceiveBlk *receiveBlkPtr,
  761.                  int ignoreDir));
  762. int   Indx_ReadIndxEntry _ARGS_ ((FILE *indxStream, T_FileStat *statInfoPtr));
  763. int   Indx_WriteIndxEntry _ARGS_ ((T_FileStat *statInfoPtr, int thdrStream,
  764.                    FILE *indxStream));
  765.  
  766.  
  767. /**************************** jmgr ****************************/
  768.  
  769. #define S_CMDNULL 0
  770. #define S_CMDLOCK 1
  771. #define S_CMDFREE 2
  772. #define S_CMDSTAT 3
  773.  
  774. typedef struct s_devstat {
  775.     int count;
  776.     char *devName;
  777.     int volId;
  778.     char *hostName;
  779.     char *userName;
  780. } S_DevStat;
  781.  
  782. typedef struct s_qstat {
  783.     int count;
  784.     int volId;
  785.     char *hostName;
  786. } S_QStat;
  787.  
  788. #endif /* _JAQUITH */
  789.  
  790.